package lambda;

import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Date;
import java.util.List;

/**
 * @title:
 * @author: yunfeis.shang
 * @date: 2018-03-28 11:43
 * @descreption:
 */
public class LambdaListDemo {
    public static void main(String[] args) {
        /*//不使用Lambda表达式
        List<String> list = Arrays.asList("1", "2", "3", "4", "5");
        for (String str : list) {
            System.out.println(str);
        }
        System.out.println("==============");
        //使用Lambda表达式
        list.forEach(n -> System.out.println(n));
        System.out.println("==============");
        //使用Java 8的方法引用更方便，方法引用由::双冒号操作符标示，
        list.forEach(System.out::println);package*/
       /* List<Student> studentList = new ArrayList<>();
        Student student1 = new Student();
        student1.setName("Mason");
        student1.setAge(20);
        student1.setSex("1");
        Student student2 = new Student();
        student2.setName("Jenny");
        student2.setAge(20);
        student2.setSex("2");
        Student student3 = new Student();
        student3.setName("Cindy");
        student3.setAge(20);
        student3.setSex("2");
        studentList.add(student1);
        studentList.add(student2);
        studentList.add(student3);
        studentList.stream().sorted((h1, h2) -> h2.getSex().compareTo(h1.getSex())).forEach(p -> System.out.println(p.getName()));
        */
        DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
        try {
            Date date1 = dateFormat.parse("2018-09-26 00:00:00");
            Date date2 = dateFormat.parse("2018-09-26 00:00:00");
            System.out.println(date1 == date2);
            System.out.println(date1.compareTo(date2) == 0);
        } catch (Exception ex) {
        }
    }
}
